class Solution {
public:
    vector<int> findAnagrams(string s, string p) {
        vector<int> hashs(26.0);
        vector<int> hashp(26,0);
        for(auto& p1:p)
            hashp[p1-'a']++;
        int sizep=p.size();
        int sizes=s.size();
        int left=0;
        int right=0;
        vector<int> count;
        while(right<sizes)
        {
            hashs[s[right]-'a']++;

            if(right-left+1>sizep)
            {
                hashs[s[left]-'a']--;
                left++;
            }
            if(right-left+1==sizep)
            {
                if(hashp==hashs)
                    count.push_back(left);
            }
            right++;
        }
        return count;
    }
};
